<!DOCTYPE html>
<html lang="en">
<head>
    <link href="js/kindeditor-4.1.10/themes/default/default.css" type="text/css" rel="stylesheet">
    <noscript>抱歉，你的浏览器不支持 JavaScript!</noscript>
    <script type="text/javascript" charset="utf-8" src="js/kindeditor-4.1.10/kindeditor-all-min.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/kindeditor-4.1.10/lang/zh_CN.js"></script>
    <meta charset="UTF-8">
    <link rel="icon" type="image/x-icon" href="img/head/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.1/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.4.1/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="css/jt.css" />
    <script type="text/javascript" src="js/jquery-easyui-1.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/jquery-easyui-1.4.1/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <title>商品修改</title>
</head>
<body>
<div style="padding:10px 10px 10px 10px">
    <form id="itemEditForm" class="itemForm" method="post">
        <input type="hidden" name="productId"/>
        <table cellpadding="5">
            <tr>
                <td><label for="item_category">商品类目:</label></td>
                <td>
                    <input type="text" name="productCategory" style="width: 280px;" id="item_category"/>
                </td>
            </tr>
            <tr>
                <td><label for="item_name">商品名称:</label></td>
                <td>
                    <input class="easyui-textbox" type="text" name="productName" data-options="required:true"
                           style="width: 280px;" id="item_name"/>
                </td>
            </tr>
            <tr>
                <td><label for="item_price">商品价格:</label></td>
                <td>
                    <input class="easyui-numberbox" type="text" name="productPrice" style="width: 280px;" id="item_price"/>
                </td>
            </tr>
            <tr>
                <td><label for="item_count">库存数量:</label></td>
                <td>
                    <input class="easyui-numberbox" type="text" name="productNum" data-options="min:1,max:99999999,precision:0,required:true" id="item_count"/>
                </td>
            </tr>
            <tr>
                <td><label for="item_img">商品图片:</label></td>
                <td>
                    <input type="text" name="productImgurl" id="item_img"/>
                </td>
            </tr>
            <tr>
                <td><label for="item_desc">商品描述:</label></td>
                <td>
                    <textarea style="width:800px;height:300px;" name="productDescription" id="item_desc"></textarea>
                </td>
            </tr>
        </table>
    </form>
    <div style="padding:5px">
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
    </div>
</div>
<script type="text/javascript">
    var itemEditEditor ;
    $(function(){
        //实例化编辑器
        itemEditEditor = KindEditorUtil.createEditor("#itemeEditForm [name=desc]");
    });

    function submitForm(){
        if(!$('#itemEditForm').form('validate')){
            $.messager.alert('提示','表单还未填写完成!');
            return ;
        }
        $.post("/products/update",$("#itemEditForm").serialize(), function(result){
            if(result.code === 200){
                $.messager.alert('提示','修改商品成功!','info',function(){
                    $("#itemEditWindow").window('close');
                    $("#itemList").datagrid("reload");
                });
            }else{
                alert(result.message);
            }
        });
    }
</script>
</body>
</html>